﻿using Crm.CrmClient;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Crm.Views
{
    public partial class AddAnswer : ChildWindow
    {
        public Soru Soru { get; set; }

        public AddAnswer(Soru soru)
        {
            InitializeComponent();
            Soru = soru;
            this.Loaded += AddAnswer_Loaded;
        }

        void AddAnswer_Loaded(object sender, RoutedEventArgs e)
        {
            if (Soru.Secenek !=null)
            {
                for (int i = 0; i < Soru.Secenek.Count; i++)
                {
                    txtAnswer.Text += Soru.Secenek[i] + "\n";
                }
            }
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            string[] Liste = txtAnswer.Text.Split(Environment.NewLine.ToCharArray());
            ObservableCollection<string> dizi = new ObservableCollection<string>();
            for (int i = 0; i < Liste.Length; i++)
            {
                dizi.Add(Liste[i]);
            }
            Soru.Secenek = dizi;
            Soru.OzelSecenek = (bool)chkOzel.IsChecked;
            txtAnswer.Text = "";
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
    }
}

